[

	// Look for this Listerator in the Listorators table, and get heuristic settings from there
	// if there are none, no problem! the defaults will work
	var('getListeratorSettings' = 'SELECT * FROM ' $table_prefix 'Listerators WHERE Keyword_URL = "' $this_Listerator'"');
	Var: 'rewAction' = ('rewAction_Blah'); 
	inline($connection_db, -sql=$getListeratorSettings);
			if(found_count == 1);
					// we have configured heuristics
					rows;
							var(
								'these'=column('Pluralized'),
								'this'=column('Singular'),
								);
							var($rewAction + '_Table') = column('Table_name');
							var($rewAction + '_Title_Field_Name') = column('Title_Field_Name');
						
							
					/rows;
			else;
			
					var(
						'these'=($this_Listerator),
						'this'=($this_Listerator),
						);
				
					if($this_Listerator->endswith('y'));
							$these->removetrailing('y');
							$these += 'ies';
							var($rewAction + '_Table') = $these;
							var($rewAction + '_Title_Field_Name') = 'Title';
					else($this_Listerator->endswith('ies'));
							$this->removetrailing('ies');
							$this += 'y';
							var($rewAction + '_Table') = $this_Listerator;
							var($rewAction + '_Title_Field_Name') = 'Title';
					else;
							$this->removetrailing('s');
							var($rewAction + '_Table') = $this_Listerator;
							var($rewAction + '_Title_Field_Name') = 'Title';
					/if;
			/if;
	/inline;
	
	
	
	var($rewAction + '_UIDfieldName') = 'UID'; //should this be in REW?
	
	// set the table for this database action 
	var('this_table' = (var($rewAction + '_Table')));
	// build the initial fields array
	var($rewAction + '_Fields'=array);

	
	//here we are going to populate an arary with informatino about the table we'lle be reading data from.
	inline($connection_db, -table=$this_table, -sql='SHOW COLUMNS FROM '+$this_table+';');
			var($this_Listerator'_cols'= array);
			if(error_msg == 'No Error');
					iterate(column_names, var('a_column'));
							var($this_Listerator'_cols')->insert($a_column);
							//$public_content += $a_column '\r';
					/iterate;
					
					
					var('field_params' = array('Field', 'Length', 'Type', 'Default', 'Required','NULL','Table')); // this is the type of information we can get out of a mysql database
					var('form_fields'=array);
					
					
					rows;
							var('this_group'=map);
							iterate($field_params, var('a_param'));
									$this_group->insert($a_param=column($a_param));
							/iterate;
							$form_fields->insert($this_group);
					/rows;
					
					iterate($form_fields, var('a_group'));
							var('field' = $a_group->find('Field'));
							var('required'=(($a_group->find('NULL')) == 'YES' ? false | true));
							var('table'=var($rewAction + '_Table'));
							var('default' = $a_group->find('Default'));
							select(true);
								case(($a_group->find('Type'))->beginswith('VarChar'));
										var('type' = $a_group->find('Type'));
										var('size') = ($type->split('(')->get(2)->removetrailing(')')&);
										var('type') = ($type->split('(')->get(1)->removetrailing('(')&);
								case(($a_group->find('Type'))->beginswith('set'));
										var('type' = $a_group->find('Type'));
										var('size') = ($type->split('(')->get(2)->removetrailing(')')&);
										var('type') = ($type->split('(')->get(1)->removetrailing('(')&);
								case(($a_group->find('Type'))->beginswith('enum'));
										var('type' = $a_group->find('Type'));
										var('length') = ($type->split('(')->get(2)->removetrailing(')')&);
								case(($a_group->find('Type'))->equals('date'));
										var('type' = $a_group->find('Type'));
										var('length'='');
										var('type') = ($type->split('(')->get(1)->removetrailing('(')&);
								case(($a_group->find('Type'))->equals('datetime'));
										var('length'='');
										var('type' = $a_group->find('Type'));
										var('type') = ($type->split('(')->get(1)->removetrailing('(')&);
								case(($a_group->find('Type'))->equals('text'));
										var('length'='');
										var('type' = $a_group->find('Type'));
										var('type') = ($type->split('(')->get(1)->removetrailing('(')&);
							/select;
							
							var('this_group'=map);
							
							iterate($field_params, var('a_param'));
									$this_group->insert($a_param=var($a_param));
							/iterate;
							
							(var($rewAction + '_Fields'))->insert($this_group);
							
							
							
					/iterate;
					
					
			else;
					$page_title = 'Oops! The server made a boo&ndash;boo';
					$public_content += '<p>'error_msg'</p>';
			/if;
	/inline;
	
	select(true);
	
	// list records
	case(string_uppercase(response_path) == string_uppercase(var($rewAction + '_pathTo')));
			$page_title = $these;
			$page_title->replace('_and_', '&nbsp&amp;&nbsp;');
			$page_title->replace('~per-cent~', '%');
			$page_title->replace('--', ': ');
			$page_title->replace('~', '&rsquo;');
			$page_title->replace('__', ' / ');
			$page_title->replace('_', ' ');
			var('page_title_base' = $these); //this is what *would* have been the title before any errors but after we do the string manipulations
			
			if(file_exists('/_Site/Listerators/'$this_Listerator'/public-list_records.lasso'));
					// app-specific
					$public_content += include('/_Site/Listerators/'$this_Listerator'/public-list_records.lasso');
			else(file_exists('/_Site/Listerators/public-list_records.lasso'));
					// site-specific
					$public_content +=include('/_Site/Listerators/public-list_records.lasso');
			else;
					//the default application listing_all
					$public_content +=include('/_Makerator/Listerators/public-list_records.lasso');
			/if;
	case(((response_path)->endswith('/Reset/')));
			If: (Variable_Defined: 'rewAction');
					Session_End: -Name=(Var: ($rewAction + '_SessionName'));
					Cookie_Set:
						(Var: ($rewAction + '_SessionName'))='kilt off',
						-Domain=(Server_Name),
						-Expires=-9000,
						-Path='/',
						;
					Session_End: -Name=(Var: ($rewAction + '_SessionName'));
					if: action_param: 'exit';
							Redirect_URL: Action_Param('exit');
					else;
							Redirect_URL: (Var: ($rewAction + '_pathTo'));
					/if;
			Else;
					 Var: 'new_exit' = (Response_Path);
					$new_exit->(RemoveTrailing: $thisLevel_Name + '/');
					Redirect_URL: '../';
			/If;
	case($show_admin_content && ((response_path)->endswith('/Reset/')));
			If: (Variable_Defined: 'rewAction');
					Session_End: -Name=(Var: ($rewAction + '_SessionName'));
					Cookie_Set:
						(Var: ($rewAction + '_SessionName'))='kilt off',
						-Domain=(Server_Name),
						-Expires=-9000,
						-Path='/',
						;
					Session_End: -Name=(Var: ($rewAction + '_SessionName'));
					if: action_param: 'exit';
							Redirect_URL: Action_Param('exit');
					else;
							Redirect_URL: (Var: ($rewAction + '_pathTo'));
							//redirect_url('../');
					/if;
			Else;
					Var: 'new_exit' = (Response_Path);
					$new_exit->(RemoveTrailing: $thisLevel_Name + '/');
					Redirect_URL: '../';
			/If;
	case((response_path)->beginswith('/'$this_Listerator'/') && (response_path)->endswith('/Search/'));
			$page_title = $these;
			if(file_exists('/_Site/Listerators/'$this_Listerator'/public-search.lasso'));
					// app-specific
					$public_content += include('/_Site/Listerators/'$this_Listerator'/public-search.lasso');
			else(file_exists('/_Site/Listerators/public-search.lasso'));
					// site-specific
					$public_content += include('/_Site/Listerators/public-search.lasso');
			else;
					//the default Makerator search
					$public_content +=include('/_Makerator/Listerators/public-search.lasso');
			/if;
	case;
	
	
			//might be a specific '$this_Listerator' item
			var('sql' = string);
			
			
			
			$sql = 'SELECT * FROM ' (var($rewAction + '_Table')) ' WHERE ' (var($rewAction + '_Table')) '.Keyword_URL = "' + $thisLevel_Name + '"';
			inline($connection_db, action_params, -sql=$sql, -inlinename=('show'+$this));
					if(found_count == 0);
							
							
							// this record no existee
							$page_title = '<code>You are standing in an empty field, looking<br>at a sign that reads "404: File Not Found"_</code>';
							
							$public_content = '<p class="">Perhaps you followed a bad link?</p>
							';
							
					
					else(error_msg != 'No Error');
					
							$public_content += '<div class="warning">'error_msg'</div>';
							$public_content += '<textarea>'action_statement'</textarea>';
					else;
					
							if(file_exists('/_Site/Listerators/'$this_Listerator'/public-details.lasso'));
									// app-specific
									$public_content += include('/_Site/Listerators/'$this_Listerator'/public-details.lasso');
							else(file_exists('/_Site/Listerators/public-details.lasso'));
									// site-specific
									$public_content += include('/_Site/Listerators/public-details.lasso');
							else;
									//the default Makerator listing_all
									$public_content +=include('/_Makerator/Listerators/public-details.lasso');
							/if;
					/if;
					
					
			/inline;
			
			
	/select;
	



]